/***************************************************************************
 *   Salatinoid - Islamic Prayer Time Plasmoid                             *
 *   Copyright (C) 2009 by Tarek Saidi  <tarek.saidi@arcor.de>             *
 *                                                                         *
 *   Bismillah ar-Rahman ar-Rahim;                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation, either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program. If not, see <http://www.gnu.org/licenses/>.  *
 ***************************************************************************/

#include "plasma-applet-salatinoid.h"
#include "plasma-applet-salatinoidconfig.h"


void Salatinoid::showConfigurationInterface(){

    if( KConfigDialog::showDialog( "settings" ) )
        return;

    if(!configDlg){
        KConfigDialogManager::propertyMap()->insert("KNotifyConfigWidget", "");
        KConfigDialogManager::changedMap()->insert("KNotifyConfigWidget", SIGNAL(changed(bool)));
        configDlg = new KConfigDialog(0, "settings", SalatinoidConfig::self() );
        configDlg->setWindowIcon(*icon);
        //Setup page general
        QWidget *w = new QWidget();
        ui_configDlg.setupUi(w);
        KPageWidgetItem *mainConfigPage = configDlg->addPage(w, i18n("General"), "General");
        mainConfigPage->setIcon(*icon);
        //Setup page notifications
        KNotifyConfigWidget* notifyWidget = new KNotifyConfigWidget(configDlg);
        notifyWidget->setApplication("plasma-applet-salatinoid", QString::null, QString::null);
        KPageWidgetItem *notifyPage = configDlg->addPage(notifyWidget, i18n("Notifications"), "Notifications");
        notifyPage->setIcon(KIcon("preferences-desktop-notification"));
        connect(configDlg,SIGNAL(applyClicked()),notifyWidget,SLOT(save()));
        connect(configDlg,SIGNAL(okClicked()),notifyWidget,SLOT(save()));
        connect(notifyWidget,SIGNAL(changed(bool)),configDlg, SLOT(enableButtonApply(bool)));

        w->adjustSize();
        configDlg->adjustSize();
        connect( configDlg, SIGNAL(settingsChanged(const QString &)),this, SLOT(updateConfiguration()) );
    }

    configDlg->show();
}

